<html>
	<head>
		<title>
			Mind Class Generator
		</title>
		<style type='text/css'>
			body, td, li
			{
				font-family: Tahoma, Sans-Serif;
				font-size:12px;
				color: #333;
			}
		</style>
		<script>
			window.onload= function(){
				document.getElementById('fName').focus();
			}
			var ucFirst= function(o){
				return o.substring(0, 1).toUpperCase() + o.substring(1, o.length);
			}
			function think()
			{
				var fName= document.getElementById('fName').value;
				var atts= document.getElementById('atts').value.replace(/ /g, '').split(',');
				var sepGetSet= document.getElementById('sepGetSet').checked;
				var withComments= document.getElementById('withComments').checked;
				var str= '';
				if(withComments)
				{
					str+= "/**\n";
					str+= "* Generate by PHPDevBar, Add-on for FireFox\n";
					str+= "* PHP Class "+ucFirst(fName)+"\n";
					str+= "* @author	Your Name Here <your@email.com>\n";
					str+= "* @link  https://addons.mozilla.org/en-US/firefox/addon/12686\n";
					str+= "* @version  1.0\n";
					str+= "*/\n";
				}
				
				str+=  "class "+ucFirst(fName)+'\n';
				str+= "{\n";
				//str+=  "\t//attributes\n";
				//var strFunc= '\n\t//functions (get and set)\n';
				var strFunc= '';
				for(var i=0; i<atts.length; i++)
				{
					str+="\tprivate $"+atts[i]+";\n";
					if(sepGetSet)
					{
						if(withComments)
						{
							strFunc+= "\n\t/**\n";
							strFunc+= "\t* Public function set"+ucFirst(atts[i])+"\n";
							strFunc+= "\t* @return void\n";
							strFunc+= "\t* @param  mixed $val\n";
							strFunc+= "\t*/\n";
						}
						strFunc+= "\tfunction set"+ucFirst(atts[i])+'($val="")\n';
						strFunc+= "\t{\n";
						strFunc+= "\t\t$this->"+atts[i]+"= $val;\n";
						strFunc+= "\t}\n";
						if(withComments)
						{
							strFunc+= "\n\t/**\n";
							strFunc+= "\t* Public function get"+ucFirst(atts[i])+"\n";
							strFunc+= "\t* @return "+atts[i]+"\n";
							strFunc+= "\t*/\n";
						}
						strFunc+= "\tfunction get"+ucFirst(atts[i])+'()\n';
						strFunc+= "\t{\n";
						strFunc+= "\t\treturn $this->"+atts[i]+";\n";
						strFunc+= "\t}\n";
					}else{
							if(withComments)
							{
								strFunc+= "\n\t/**\n";
								strFunc+= "\t* Public function "+atts[i]+"\n";
								strFunc+= "\t* @return "+atts[i]+"|void\n";
								strFunc+= "\t* @param  mixed|void $val\n";
								strFunc+= "\t*/\n";
							}
							strFunc+= "\tfunction "+atts[i]+"($val=false)\n";
							strFunc+= "\t{\n";
							strFunc+= "\t\tif($val)\n\t\t\t$this->"+atts[i]+"= $val;\n";
							strFunc+= "\t\telse\n\t\t\treturn $this->"+atts[i]+";\n";
							strFunc+= "\t}\n";
						 }
				}
				str+= strFunc;
				str+= "}\n";
				document.getElementById('code').value= str;
			}
		</script>
	</head>
	<body bgcolor="#e6e6df">
		<table style="width:100%;height:100%;">
			<tr style='height:22px;'>
				<td>
					Class Name
				</td>
				<td>
					<input type='text'
						   id='fName'>
				</td>
			</tr>
			<tr style='height:22px; width: 250px;'>
				<td>
					Attributes ("," coma separated)
				</td>
				<td>
					<input type='text'
						   id='atts'
						   style='width:300px;'>
				</td>
			</tr>
			<tr style='height:22px;'>
				<td colspan='2'>
					<input type='checkbox'
						   id='sepGetSet'>
					Separated Get and Set
					&nbsp;&nbsp;&nbsp;
					<input type='checkbox'
						   id='withComments'
						   checked='checked'>
					With Comments
				</td>
			</tr>
			<tr style='height:22px;'>
				<td colspan='2'>
					<center>
						<input type='button'
							   value='Generate It'
							   onclick="think()">
					</center>
				</td>
			</tr>
			<tr>
				<td colspan='2'>
					<textarea id="code"
							  readonly='readonly'
							  style='background-color:#fff;
									 color:#333;
									 width:100%;
									 height:100%;'></textarea>
				</td>
			</tr>
		</table>
	</body>
</html>